home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: FORTRAN and floats
- Date: 26 Mar 96 02:12:44 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.827806364@rscernix>
- References: <4j6on8$fif@mozo.cc.purdue.edu>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4j6on8$fif@mozo.cc.purdue.edu> rwa@bragg.bio.purdue.edu writes:
-
- >I'm sure this is an easy one ... ;-)
-
- Indeed :-)
-
- >I write a "float" from C in Ultrix to a disk file as follows:
- >
- > fwrite(&myFloat,sizeof(float),1,fOut);
- >
- >I get over to my Alpha Open VMS box and try and read it with FORTRAN and
- >get gibberish. (Also can't do when writing from FORTRAN/VMS and reading in Ultrix/C).
- >
- >So FORTRAN/VMS likes a different format for floats than C/Ultrix.
-
- Fortran on OpenVMS can be convinced to use the same representation
- for floats as the Ultrix system (IEEE 754), but this won't fix your
- problem. You have to do additional tricks in the Fortran code to be
- able to read a binary file which wasn't produced by a Fortran program
- on the same platform.
-
- >This is a portability issue that I'm sure there's a "clean" way to
- >solve it - does anyne have any ideas for me???
-
- The clean and portable solution is to avoid binary files. They're a pain
- in the ass even on the same platform, when they have to be used by
- programs written in different languages. So, write your data in text
- format and both systems will understand it.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-